package com.asl.website.jobPosition.domain;

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-06-02
 */

public class JobPositionDetailsDTO {
    private Long id;
    private String title;
    private String location;
    private Integer sortOrder;
    private String description;
    private Integer status;
    private String language;

    public JobPositionDetailsDTO(AslJobPosition position, String language) {
        this.id = position.getId();
        this.sortOrder = position.getSortOrder();
        this.status = position.getStatus();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(position.getTitleEn(), position.getTitleZh());
                this.location = StringUtils.firstNonBlank(position.getLocationEn(), position.getLocationZh());
                this.description=StringUtils.firstNonBlank(position.getDescriptionEn(),position.getDescriptionZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(position.getTitleDe(), position.getTitleZh());
                this.location = StringUtils.firstNonBlank(position.getLocationDe(), position.getLocationZh());
                this.description=StringUtils.firstNonBlank(position.getDescriptionDe(),position.getDescriptionDe());
                break;
            default: // 默认中文
                this.title = position.getTitleZh();
                this.location = position.getLocationZh();
                this.description=position.getDescriptionZh();
        }
    }

    // getters
    public Long getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public String getLocation() {
        return location;
    }

    public String getDescription() {
        return description;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public Integer getStatus() {
        return status;
    }


    public String getLanguage() {
        return language;
    }
}
